﻿<%@ Page Title="" Language="C#" MasterPageFile="~/manager/page/ManagerMasterPage.Master" AutoEventWireup="true" CodeBehind="store.aspx.cs" Inherits="Com.Web.coffinegurunaru.manager.banner.store" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phContent" runat="server">
<hr />
<br />
<table>
<tr>
	<td valign="top">
		<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:100px;">
		<tr>
			<td style="background-color:White; text-align:center; height:50px;"><a href="/manager/banner/">매인페이지</a></td>
		</tr>
		<tr>
			<td style="background-color:White; text-align:center; height:50px;"><a href="popup.aspx">팝업</a></td>
		</tr>
		<tr>
			<td style="background-color:Silver; text-align:center; height:50px;"><a href="store.aspx">Store</a></td>
		</tr>
		</table>
	</td>
	<td style="width:20px;"></td>
	<td>
		<table width="100%" height="100%" border="0">
		<tr>
			<td id="m_UserList" valign="top" width="560">
				[매장 리스트]
				<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:400;" class="m_UserList">
				<tr>
					<td></td>
				</tr>
				</table>
				<table style="width:100%; height:30px;">
				<tr>
					<td style="text-align:center;"><div id="m_Pager"></div></td>
				</tr>
				</table>
			</td>
			<td style="width:10px;"></td>
			<td valign="top">
				<div id="m_Input">
				<table cellpadding="0" cellspacing="1" style="background-color:Gray; width:400;">
				<tr style="width:100%; height:20px; background-color:#ffffff;">
					<td style="text-align:center; width:150px;">아이디</td>
					<td style="width:300px;"></td>
				</tr>
				<tr style="width:100%; height:20px; background-color:#ffffff;">
					<td style="text-align:center;">가맹점명</td>
					<td></td>
				</tr>
				<tr style="width:100%; height:20px; background-color:#ffffff;">
					<td style="text-align:center;">가맹점 이름이미지</td>
					<td><input type="text" class="m_TitleImageURL" readonly="readonly" style="width:200px;" /><input type="button" value="이미지선택" class="m_btnTitleImage"/></td>
				</tr>
				<tr style="width:100%; height:20px; background-color:#ffffff;">
					<td style="text-align:center;">가맹점선택 이름이미지</td>
					<td><input type="text" class="m_TitleOverImageURL" readonly="readonly" style="width:200px;" /><input type="button" value="이미지선택" class="m_btnTitleOverImage"/></td>
				</tr>
				<tr style="width:100%; height:20px; background-color:#ffffff;">
					<td style="text-align:center;">가맹점이미지</td>
					<td><input type="text" class="m_ImageURL" readonly="readonly" style="width:200px;" /><input type="button" value="이미지선택" class="m_btnImage"/></td>
				</tr>
				<tr>
					<td colspan="2" style="text-align:center; background-color:#ffffff;"><input type="button" value="저장" class="btnSave" /></td>
				</tr>
				</table>
				</div><br />
				<div id="m_List">
				<table cellpadding="0" cellspacing="1" style="background-color:#000000;">
				<tr style="background-color:#eeeeee; height:30px;" >
					<td style="text-align:center; width:150px;">아이디</td>
					<td style="text-align:center; width:150px;">가맹점명</td>
					<td style="text-align:center; width:200px;">가맹점명이미지</td>
					<td style="text-align:center; width:200px;">가명점이미지</td>
					<td style="text-align:center; width:50px;">-</td>
				</tr>
				</table>
				</div>
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>

<script language="javascript" type="text/javascript">
(function($) {
	$.Store = {};

	$.Store = {
		PageNo : 1,
		
		
		Init : function() {
			$("#m_Pager").pager({
				pageSize : 20,
				useCallback : true,
				pageNo : 1,
				callback:function(pageNo) {
					$.Store.StoreList();
				}
			});
			
			$.Store.StoreList();
			$.Store.MainStoreList();
			
			$("#m_Input input.m_btnTitleImage").click(function() {
				$.manager.fileopen(10, "$.Store.FileOpen_Title");
			});
			$("#m_Input input.m_btnTitleOverImage").click(function() {
				$.manager.fileopen(11, "$.Store.FileOpen_TitleOver");
			});
			$("#m_Input input.m_btnImage").click(function() {
				$.manager.fileopen(12, "$.Store.FileOpen_Image");
			});
			$("#m_Input input.btnSave").click(function() {
				$.Store.Save();
			});
		},
		
		FileOpen_Title : function(url)
		{
			$("#m_Input input.m_TitleImageURL").val(url);
		},
		
		FileOpen_TitleOver : function(url)
		{
			$("#m_Input input.m_TitleOverImageURL").val(url);
		},
		
		FileOpen_Image : function(url)
		{
			$("#m_Input input.m_ImageURL").val(url);
		},
		
		StoreList : function() {
			$("#m_UserList").ajaxNet(
			"/manager/store/storemethod.aspx?_vb=GetStoreSimpleList",
			{
				"IsActive": "Y"
			,	"PageNo": $("#m_Pager").pager("option", "currentPageNo")
			,	"PageSize": $("#m_Pager").pager("option", "pageSize")
			}, function(results, context) {
				$("#m_UserList>table.m_UserList>tbody").html($(results[0]))
					.find("input.m_btnNewOpenStore").click(function() {
						$(this).closest("tr").parent().find("tr:gt(0)").css({"background-color":"#ffffff"});
						$(this).closest("tr").css({"background-color":"#eeeeee"});
						$.Store.StoreInfo( $(this).closest("tr") );
					});
				$("#m_Pager").pager("update", results[1]);
			});
		},
		
		MainStoreList : function() {
			$("#m_List").ajaxNet(
			"/manager/banner/storemethod.aspx?_vb=MainStoreList",
			{
			}, function(results, context) {
				$("#m_List>table tbody").html(results);
				$("#m_List>table button.m_Remove").click(function() {
					$.Store.Remove( $(this).closest("tr") );
				});
			});
		},
		
		StoreInfo : function( $tr ) {
			var data = $tr.tagdata();
			$("#m_Input").tagdata().StoreNo = data.StoreNo;
			$("#m_Input tr:eq(0) td:eq(1)").text( $tr.find("td:eq(0)").text() );
			$("#m_Input tr:eq(1) td:eq(1)").text( $tr.find("td:eq(1)").text() );
		},
		
		Remove : function( $tr ) {
			var data = $tr.tagdata();
			if ( confirm("정말로 삭제하시겠습니까?") ) {
				$tr.ajaxNet(
				"/manager/banner/storemethod.aspx?_vb=MainRemove",
				{
					"StoreNo": StoreNo
				}, function(results, context) {
					$.Store.MainStoreList();
				});
			}
		},
		
		Save : function() {
			var StoreNo = $("#m_Input").tagdata().StoreNo;
			var TitleImageURL = $("#m_Input input.m_TitleImageURL").val();
			var TitleOverImageURL = $("#m_Input input.m_TitleOverImageURL").val();
			var ImageURL = $("#m_Input input.m_ImageURL").val();
			
			if ( StoreNo == undefined )
			{
				alert( "가맹점을 선택하세요" );
				return;
			}
			
			$("#m_Input").ajaxNet(
			"/manager/banner/storemethod.aspx?_vb=MainStoreCreate",
			{
				"StoreNo": StoreNo
			,	"TitleImageURL": TitleImageURL
			,	"TitleOverImageURL": TitleOverImageURL
			,	"ImageURL": ImageURL
			}, function(results, context) {
				$.Store.MainStoreList();
			});
		}
	}
	
	$(function() {
		$.Store.Init();
	});
})(jQuery);

</script>

</asp:Content>
